package com.topsoft.micro.security;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;


@Component
public class MyUserDetailsService implements UserDetailsService{

    private static final Logger LOGGER = LoggerFactory.getLogger(MyUserDetailsService.class);
    
    
    
   // @Autowired
   // private PasswordEncoder passwordEncoder;


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        LOGGER.info("表单登录用户名：{}", username);
        
        //这里是  前端  加密!!!!  正常  后端  没有这个   
       // String password = passwordEncoder.encode("123456");
        
        String password ="123456";
        
        
        LOGGER.info("表单登录密码：{}", password);
        
        
        return new User(username, 
        		password,
        		true,   //可用
        		true,   //账户过期
        		true,  //认证过期
        		true, //锁定用户
        		AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
    }
    
    
    
    



}
